package com.ll.micropoint.point.service.Impl;

import com.ll.common.core.entity.PointRule;
import com.ll.common.redis.utils.RedisUtils;
import com.ll.micropoint.point.mapper.PointInfoMapper;
import com.ll.micropoint.point.mapper.PointRuleMapper;
import com.ll.micropoint.point.service.IPointRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Collections;
import java.util.List;

@Service
public class PointRuleServiceImpl implements IPointRuleService {

    @Autowired
    private PointRuleMapper pointRuleMapper;

    @Autowired
    private RedisUtils redisUtils;

    @Override
    public List<PointRule> pointlist() {
        List<PointRule> pointRuleList = redisUtils.getCacheObject("point:rule");
        //缓存中没有数据,查询,存进去
        if (ObjectUtils.isEmpty(pointRuleList)){
//            List<PointRule> pointlist = pointRuleService.pointlist();
            List<PointRule> pointlist = pointRuleMapper.selectList(null);
            redisUtils.setCacheObject("point:rule",pointlist);
        }
        return pointRuleMapper.selectList(null);
    }
}
